const lowCodeInstance = Symbol("lowCodeInstance");
import clone from "clone";
import { v4 as uuidv4 } from "uuid";
import { tools } from "../page-designer/utils";
import { CellImp, LowCodeImp, ComponentImp } from './type'
export class Cell implements CellImp {
  private [lowCodeInstance]: LowCodeImp;
  private metaRefresh?: string;
  key!: string;
  type!: string;
  options: any;
  items!: Array<ComponentImp | CellImp>;
  [prop: string]: any
  constructor(options: { [x: string]: any; hasOwnProperty: (arg0: string) => any; }, lowcode: LowCodeImp, newKey?: boolean) {
    for (let name in options) {
      if (options.hasOwnProperty(name)) {
        this[name] = clone(options[name]);
      }
    }
    this[lowCodeInstance] = <LowCodeImp>lowcode
    if (!this.key || newKey) {
      this.key = uuidv4()
    }
  }


  updateMetaRefresh() {
    this.metaRefresh = uuidv4()
  }
  getLowCodeInstance() {
    return this[lowCodeInstance]
  }

}